load-helpers
Load helpers with patterns, as an object, key-value pair, or module.
Install
Install with npm:
$ npm install --save load-helpers
Usage
var loader = require('load-helpers');
var cache = {};
var helpers = loader(cache);
helpers({
a: function() {},
b: function() {},
c: function() {}
});
helpers('d', function() {});
helpers('e', function() {});
helpers('f', function() {});
helpers('helpers/*.js');
helpers('j');
Results in:
{
a: function(){},
b: function(){},
c: function(){},
d: function(){},
e: function(){},
f: function(){},
g: function(){},
h: function(){},
i: function(){},
j: function(){}
}
options.renameKey
When requiring helpers from a filepath or node_modules
a renameKey
function may be passed on the helper's options to customize how the key is named:
Example
helpers('for-own', {
renameKey: function (key) {
return key.replace(/\W(.)/g, function (_, ch) {
return ch.toUpperCase();
});
}
});
About
Related projects
- handlebars-helpers: More than 130 Handlebars helpers in ~20 categories. Helpers can be used with Assemble, Generate… more | homepage
- helper-cache: Easily register and get helper functions to be passed to any template engine or node.js… more | homepage
- template-helpers: Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or… more | homepage
- templates: System for creating and managing template collections, and rendering templates with any node.js template engine… more | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)
To generate the readme and API documentation with verb:
$ npm install -g verb verb-generate-readme && verb
Running tests
Install dev dependencies:
$ npm install -d && npm test
Author
Jon Schlinkert
License
Copyright © 2016, Jon Schlinkert.
Released under the MIT license.
This file was generated by verb, v0.9.0, on July 23, 2016.